<!--
Note: Script consists of two files: calendar?.js and calendar.html
-->
<html>
<head>
<title>Select Date, Please.</title>
<style>
	td {font-family: Tahoma, Verdana, sans-serif; font-size: 12px;}
</style>
<script language="JavaScript">

 var YR_L_LIMIT=1600;
 var YR_U_LIMIT=2099;
 var re_yr_limits=/^(([1][6-9]|[2][0])[0-9][0-9])$/

// months as they appear in the calendar's title
var ARR_MONTHS = ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"];
// week day titles as they appear on the calendar
var ARR_WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
// day week starts from (normally 0-Su or 1-Mo)
var NUM_WEEKSTART = 1;
// path to the directory where calendar images are stored. trailing slash req.
var STR_ICONPATH = 'img/';
//*****************************************************/
var re_url = new RegExp('datetime=(\\-?\\d+)');
var dt_current = (re_url.exec(String(window.location))
	? new Date(new Number(RegExp.$1)) : new Date());
var re_id = new RegExp('id=(\\d+)');
var num_id = (re_id.exec(String(window.location))
	? new Number(RegExp.$1) : 0);
var obj_caller = (window.opener ? window.opener.calendars[num_id] : null);
//******************************************************/
if (obj_caller && obj_caller.year_scroll) {
	// get same date in the previous year
	var dt_prev_year = new Date(dt_current);
	dt_prev_year.setFullYear(dt_prev_year.getFullYear() - 1);
	if (dt_prev_year.getDate() != dt_current.getDate())
		dt_prev_year.setDate(0);

	// get same date in the next year
	var dt_next_year = new Date(dt_current);
	dt_next_year.setFullYear(dt_next_year.getFullYear() + 1);
	if (dt_next_year.getDate() != dt_current.getDate())
		dt_next_year.setDate(0);
}

// get same date in the previous month
var dt_prev_month = new Date(dt_current);
dt_prev_month.setMonth(dt_prev_month.getMonth() - 1);
if (dt_prev_month.getDate() != dt_current.getDate())
	dt_prev_month.setDate(0);

// get same date in the next month
var dt_next_month = new Date(dt_current);
dt_next_month.setMonth(dt_next_month.getMonth() + 1);
if (dt_next_month.getDate() != dt_current.getDate())
	dt_next_month.setDate(0);

// get first day to display in the grid for current month
var dt_firstday = new Date(dt_current);
dt_firstday.setDate(1);
dt_firstday.setDate(1 - (7 + dt_firstday.getDay() - NUM_WEEKSTART) % 7);

// function passing selected date to calling window
function set_datetime(n_datetime, b_close) {

	if (!obj_caller) return;

	var dt_datetime = obj_caller.prs_time(
		(document.cal ? document.cal.time.value : ''),
		new Date(n_datetime)
	);

	if (!dt_datetime) return;


	if(dt_datetime.getFullYear()< YR_L_LIMIT)
		{
			dt_datetime.setFullYear(YR_L_LIMIT);
		 	if(dt_datetime.getMonth()==11)
		 		dt_datetime.setMonth(0);
		}

	if(dt_datetime.getFullYear()> YR_U_LIMIT)
		{
			dt_datetime.setFullYear(YR_U_LIMIT);
		 	if(dt_datetime.getMonth()==0)
		 		dt_datetime.setMonth(11);
		}
	if (b_close) {
		window.close();
		obj_caller.target.value = (document.cal
			? obj_caller.gen_tsmp(dt_datetime)
			: obj_caller.gen_date(dt_datetime)
		);
	}
	else obj_caller.popup(dt_datetime.valueOf(), window.location.href);


}

</script>
</head>
<body bgcolor="#FFFFFF" marginheight="5" marginwidth="5" topmargin="5" leftmargin="5" rightmargin="5">
<table class="clsOTable" cellspacing="0" border="0" width="100%">
<tr><td bgcolor="#4682B4">
<table cellspacing="1" cellpadding="3" border="0" width="100%">
<tr><td colspan="7"><table name="prash" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<script language="JavaScript">
//New Code added-> on 16Aug prashant*/
//Shows select box, hides label of month
function showHideM()
{
	 selM.style.visibility='visible';
 	 selM.focus();
 	 lblmonth.style.visibility='hidden';
 	 lblyr.style.left=150;
 	 //lblyr.style.top=13;

}

//Shows label hides select box, of month
function hideShowM()
{
	lblmonth.style.visibility='visible';
	selM.style.visibility='hidden';
	lblyr.style.left=140;
}

//Shows text hides label of year
function showHideY()
{
	yr.style.visibility='visible';
	yr.focus();
	yr.select();
//	yr.value='';    if not commented, .focus() & .select() should be checked

	lblyr.style.visibility='hidden';

}
//Shows label hides text  of year
function hideShowY()
{
	yr.style.visibility='hidden';
	lblyr.style.visibility='visible';
}

//Sets year and also checks the format of the entered year
function yearSet()
{


	var arg=yearSet.arguments; //arg[0]>>Valid year to be modified
	//var re_yr_limits=/^(([1][6-9]|[2][0])[0-9][0-9])$/ //DEFINED ABOVE

	var temp='';
	var st=yr.value;
	var pt=arg[0];

	if(!re_yr_limits.test(st))
		{
			yr.value=pt;
			alert('Please enter year in YYYY format [1600 to 2099] ');

			yr.style.visibility='hidden';
			lblyr.style.visibility='visible';

		}
	else
		{

		var dt_new_year = new Date(dt_current);
		dt_new_year.setFullYear(yr.value);
		if (dt_new_year.getDate() != dt_current.getDate())
			dt_new_year.setDate(0);
		javascript:set_datetime(dt_new_year.valueOf());

		yr.style.visibility='hidden';
		lblyr.value=yr.value;
		lblyr.style.visibility='visible';
		return;

		}
}

//Set Month through Random Selection in Combo
function monthSet()
{
	var l=0;

		for(l=0; l < selM.length; l++)
			if(selM.options[l].selected)
				break;

		var dt_next_month = new Date(dt_current);
		dt_next_month.setMonth(l);
		if (dt_next_month.getDate() != dt_current.getDate())
			dt_next_month.setDate(0);

		lblmonth.value=dt_next_month.valueOf();

		javascript:set_datetime(dt_next_month.valueOf());
		return;

}

function yrEnter()
{
if(event.keyCode==13)
	yearSet(dt_current.getFullYear());
}
//******************/

document.write(
'<td>'+(obj_caller&&obj_caller.year_scroll?'<a href="javascript:set_datetime('+dt_prev_year.valueOf()+')"><img src="'+STR_ICONPATH+'prev_year.gif" width="16" height="16" border="0" alt="previous year"></a>&nbsp;':'')+'<a href="javascript:set_datetime('+dt_prev_month.valueOf()+')"><img src="'+STR_ICONPATH+'prev.gif" width="16" height="16" border="0" alt="previous month"></a></td>'+
'<td align="center" width="100%">');

//*******/
document.write(' <label name="lblmonth" id="lblmonth" Style="POSITION:ABSOLUTE; visibility: visible; right:115; top:10; " title="click to select month" align=right onClick=showHideM()><font color=#ffffff><b>'+ARR_MONTHS[dt_current.getMonth()]+' '+'<b></font></label>');
document.write('<select name="selM" id="selM" Style="POSITION:ABSOLUTE; visibility: hidden; left:50; top:8; " onChange=monthSet()  onBlur=hideShowM()>');
	 for(var ijk=0;ijk<12;ijk++)
		if(ijk!=dt_current.getMonth())
			document.write('<option>'+ARR_MONTHS[ijk]+'</option>');
		else
			document.write('<option selected>'+ARR_MONTHS[ijk]+'</option>');
		document.write('</select ></td>');
///******/
document.write('<td><label id="lblyr" name="lblyr" Style="POSITION:ABSOLUTE; visibility:visible;left:135; top:10; " title="click to enter year" onClick=showHideY()><font color="#faffaf"><b>'+dt_current.getFullYear()+'</b></font></label>');
document.write('<input id="yr" name="yr" type="text"  title="Enter the year as YYYY from [1600-2099]" Style="POSITION:ABSOLUTE;visibility:hidden;left:135;top:10; background-color:#87cefa; color:#00550f; font-weight:bold; border-width:0; border-right-width:1; border-bottom-width:1; "  maxlength="4" size="2" value="'+dt_current.getFullYear()+'" onChange=yearSet("'+dt_current.getFullYear()+'") onBlur=hideShowY() onKeyPress=yrEnter()></td>');
//******/

document.write('<td><a href="javascript:set_datetime('+dt_next_month.valueOf()+')"><img src="'+STR_ICONPATH+'next.gif" width="16" height="16" border="0" alt="next month"></a>'+(obj_caller && obj_caller.year_scroll?'&nbsp;<a href="javascript:set_datetime('+dt_next_year.valueOf()+')"><img src="'+STR_ICONPATH+'next_year.gif" width="16" height="16" border="0" alt="next year"></a>':'')+'</td>');
</script>
</tr>
</table></td></tr>
<tr>
<script language="JavaScript">

// print weekdays titles
for (var n=0; n<7; n++)
	document.write('<td bgcolor="#87cefa" align="center"><font color="#ffffff">'+ARR_WEEKDAYS[(NUM_WEEKSTART+n)%7]+'</font></td>');
document.write('</tr>');

// print calendar table
var dt_current_day = new Date(dt_firstday);

//****/
var ROWS=0;    //For changing the Window frame size : (prash)
//****/

while (dt_current_day.getMonth() == dt_current.getMonth() ||
	dt_current_day.getMonth() == dt_firstday.getMonth()) {
ROWS++;
	// print row heder
	document.write('<tr>');
	for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
		if (dt_current_day.getDate() == dt_current.getDate() &&
			dt_current_day.getMonth() == dt_current.getMonth())
			// print current date
			document.write('<td bgcolor="#ffb6c1" align="center" width="14%">');
		else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
			// weekend days
			document.write('<td bgcolor="#dbeaf5" align="center" width="14%">');
		else
			// print working days of current month
			document.write('<td bgcolor="#ffffff" align="center" width="14%">');

		document.write('<a href="javascript:set_datetime('+dt_current_day.valueOf() +', true);">');

		if (dt_current_day.getMonth() == this.dt_current.getMonth())
			// print days of current month
			document.write('<font color="#000000">');
		else
			// print days of other months
			document.write('<font color="#606060">');

		document.write(dt_current_day.getDate()+'</font></a></td>');
		dt_current_day.setDate(dt_current_day.getDate()+1);
	}
	// print row footer
	document.write('</tr>');
}
//***if month is feb eg. feb 2010*//
if(ROWS<5)
	{
		window.resizeTo(250,171); //171+0
		window.innerWidth=250;

		window.innerHeight=160; // To avoid overlapping Status bar etc,(e.g. mozilla)

	}
else if(ROWS==5)
	{
		window.resizeTo(250,192); //171+21
		window.innerWidth=250;

		window.innerHeight=180;  //+20

	}


else if(ROWS>5)
	{
		window.resizeTo(250,213);//171+21+21
		window.innerWidth=250;

		window.innerHeight=200; //+20
	}

if (obj_caller && obj_caller.time_comp)
	document.write('<form onsubmit="javascript:set_datetime('+dt_current.valueOf()+', true)" name="cal"><tr><td colspan="7" bgcolor="#87CEFA"><font color="White" face="tahoma, verdana" size="2">Time: <input type="text" name="time" value="'+obj_caller.gen_time(this.dt_current)+'" size="8" maxlength="8"></font></td></tr></form>');


</script>
</table></tr></td>
</table>
</body>
</html>

